package org.springcloud.wisdom.springcloud_03_freshman.admin.controller;

import org.springcloud.wisdom.springcloud_03_freshman.admin.service.AdminDormService;
import org.springcloud.wisdom.springcloud_03_freshman.common.bean.ResponseData;
import org.springcloud.wisdom.springcloud_03_freshman.common.controller.BaseController;
import org.springcloud.wisdom.springcloud_03_freshman.student.entity.Dormitory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/dorm")
public class AdminDormController  extends BaseController {
    @Autowired
    AdminDormService adminDormService;

    @RequestMapping("/all")
    public ResponseData<Object> getDormPage(@RequestParam("pageNum") int pageNum,
                                            @RequestParam("pageSize")int pageSize){
        return returnObject(adminDormService.getDormPage(pageNum, pageSize));
    }

    @PostMapping("/add")
    public ResponseData<Boolean> add(Dormitory dormitory){
        return returnBoolean(adminDormService.add(dormitory));
    }

    @PutMapping("/update")
    public ResponseData<Boolean> update(@RequestBody Dormitory dormitory){
        return returnBoolean(adminDormService.update(dormitory));
    }
}
